﻿using System;
using System.Collections.Generic;
using ZhiKeDuoServer.Model;
using IDAL;

namespace DAL
{
    public class GoodsInfoService : Base<GoodsInfo>
    {
 

        public bool Delete(string Code)
        {
           return DB.Client.Deleteable<ZhiKeDuoServer.Model.GoodsInfo>().Where(t=>t.Code==Code).ExecuteCommand() > 0;
        }




        public bool Exists(string Code)
        {
            return DB.Client.Queryable<GoodsInfo>().Where(t => t.Code == Code).Any();
        }



        public bool UpdateCount(int counts, string code)
        {
            return DB.Client.Updateable<GoodsInfo>().UpdateColumns(it => new GoodsInfo() { Counts = it.Counts + counts }).Where(it => it.Code == code).ExecuteCommandHasChange();
        }

        public GoodsInfo GetModel(string code)
        {
            return DB.Client.Queryable<GoodsInfo>().Where(t => t.Code == code).First();
        }
    }
}